<template>
	<view class="container">
 		<!-- <web-view :webview-styles="webviewStyles" :src="src"></web-view> -->
		<iframe :src="src"></iframe>
		<view class="btn-back" @click="doback">
			<image src="../../static/img/btn-back.png"></image>
		</view>
	</view>
</template>


<script>
	import api from '@/api/index.js'
 	export default {
		data() {
			return {
				webviewStyles: {
					progress: {
						color: 'red'
					}
				},
				src:''
			}
		},
		onLoad(options){
			console.log(options)
			if(options.src) {
				this.src = decodeURIComponent(options.src)
			}
			setTimeout(()=>{
				this.getShare();
			}, 500)
		},
		methods: {
			doback(){
				uni.navigateBack();
			},
			
			getShare(){
				 const that = this;	
				 let uuid = "";
				 if(this.$route.query.uuid) {
				 	uuid = this.$route.query.uuid;
				 	uni.setStorageSync('uuid', uuid)
				 }
				 else {
				 	uuid = uni.getStorageSync('uuid');
				 }
				 api.getRequest('shareData', {
				 	uuid:uuid,
					url:window.location.href
				 }).then((res)=>{
					 let response = res.data;
					 console.log('set setting', response);
					 
					 that.setShare(response.setting);
				 });
			},
			setShare(setting){
				let link = setting.shareLink;
				// if(uuid) link+='&uuid='+uuid;
				window.jWeixin.updateAppMessageShareData({ 
					title: setting.shareTitle, // 分享标题
					desc: setting.shareDesc, // 分享描述
					link: link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
					imgUrl: setting.shareImg, // 分享图标
				});
				
				window.jWeixin.updateAppMessageShareData({
					title: setting.shareTitle, // 分享标题
					desc: setting.shareDesc, // 分享描述
					link: link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
					imgUrl: setting.shareImg, // 分享图标
				});
				window.jWeixin.onMenuShareAppMessage({
					title: setting.shareTitle, // 分享标题
					desc: setting.shareDesc, // 分享描述
					link: link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
					imgUrl: setting.shareImg, // 分享图标
				});
				window.jWeixin.onMenuShareTimeline({
					title: setting.shareTitle, // 分享标题
					desc: setting.shareDesc, // 分享描述
					link: link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
					imgUrl: setting.shareImg, // 分享图标
				});
			}
				
		}
	}
</script>
<style scoped>
	.btn-back{
		position: fixed;
		bottom: 20rpx;
		right: 20rpx;
		height: 90rpx;
		width: 300rpx;
		z-index: 999999 !important;
	}
		
	.btn-back image{
		height: 100%;
		width: 100%;
	}
	iframe{
		position: absolute;
		left: 0;
		top: 0;
		right: 0;
		bottom: 0;
		height: 100%;
		width: 100%;
		border: none;   
	}
</style>
<style>
	@import '@/static/css/common.css';
</style>
 